package cn.valo.basic.service.impl;

import cn.valo.basic.mapper.BaseMapper;
import cn.valo.basic.query.BaseQuery;
import cn.valo.basic.service.BaseService;
import cn.valo.basic.util.PageList;
import cn.valo.user.mapper.LogininfoMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BaseServiceImpl<T> implements BaseService<T> {
    @Autowired
    private BaseMapper<T> mapper;
    @Override
    public void save(T t) {
        mapper.insert(t);
    }

    @Override
    public void removeById(Long id) {
        mapper.deleteById(id);
    }

    @Override
    public void update(T t) {
        mapper.update(t);
    }

    @Override
    public List<T> queryAll() {
        return mapper.queryAll();
    }

    @Override
    public T queryById(Long id) {
        return mapper.queryById(id);
    }

    @Override
    public PageList<T> queryPage(BaseQuery tQuery) {
        return new PageList<T>(mapper.queryCount(tQuery),mapper.queryPage(tQuery)) ;
    }

    @Override
    public Long queryCount(BaseQuery tQuery) {
        return mapper.queryCount(tQuery);
    }

    @Override
    public void remove(List<Long> ids) {
        mapper.delete(ids);
    }
}
